home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / RxMUI / Examples / DL.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2004-01-31  |  6.0 KB  |  182 lines

  1. /* Dirlist example */
  2.  
  3. signal on halt
  4. signal on break_c
  5.  
  6. call Init
  7. call CreateApp
  8. call HandleApp
  9. /* never reached */
  10. /***********************************************************************/
  11. Init: procedure expose global.
  12.     l="rmh.library";if ~show("L",l) then;if ~AddLib(l,0,-30) then exit
  13.     if AddLibrary("rexxsupport.library","rxmui.library")~=0 then exit
  14.     call Pragma("W","N")
  15.     call RxMUIOpt("DebugMode ShowErr")
  16.     return
  17. /***********************************************************************/
  18. CreateApp: procedure expose global.
  19.  
  20.     app.Title="DirlistExample"
  21.     app.Version="$VER: DirlistExample 2.0 (10.12.2001)"
  22.     app.Copyright="Copyright © 2001 by Alfonso Ranieri"
  23.     app.Author="Alfonso Ranieri"
  24.     app.Description="Dirlist"
  25.     app.Base="RXMUIEXAMPLE"
  26.     app.SubWindow="win"
  27.      win.ID="MWIN"
  28.      win.Title="DirlistExample"
  29.      win.Contents="mgroup"
  30.  
  31.       mgroup.0="lv"
  32.        lv.Class="Listview"
  33.        lv.List="dirl"
  34.         dirl.Class="Dirlist"
  35.         dirl.Directory=pragma("D")
  36.         dirl.Frame="ReadList"
  37.         dirl.ShowTitle=1
  38.  
  39.       mgroup.1="ig"
  40.        ig.class="group"
  41.        ig.horiz=1
  42.        ig.frame="text"
  43.        ig.background="textback"
  44.         ig.0=Text("info",,"none","none")
  45.         ig.1="lamp"
  46.          lamp.class="Lamp"
  47.  
  48.       mgroup.2=Text("ainfo")
  49.  
  50.       mgroup.3="g"
  51.        g.class="group"
  52.        g.frame="group"
  53.        g.background="groupback"
  54.         g.0="cg"
  55.          cg.class="group"
  56.          cg.columns=2
  57.           cg.0=Label("_Drawer")
  58.           cg.1=String("dir","d",dirl.Directory)
  59.           cg.2=Label("_Accept")
  60.           cg.3=String("ap","a")
  61.           cg.4=Label("R_eject")
  62.           cg.5=String("rp","e")
  63.           cg.6=Label("Sort order")
  64.           cg.7=MakeObj("stype","Cycle","Name|Date|Size")
  65.           cg.8=Label("Sort dirs")
  66.           cg.9=MakeObj("sdirs","Cycle","First|Last|Mix")
  67.         g.1=hbar()
  68.          fg.class="group"
  69.          fg.Columns=4
  70.           fg.0=Label("Au_to")
  71.           fg.1=Checkmark("ar",1,"t")
  72.           fg.2=Label("Dirs _only")
  73.           fg.3=Checkmark("do",,"o")
  74.           fg.4=Label("_Files only")
  75.           fg.5=Checkmark("fo",,"f")
  76.           fg.6=Label("No _icons")
  77.           fg.7=Checkmark("ri",,"i")
  78.         g.2=MakeObj(,"HCenter","fg")
  79.  
  80.       mgroup.4="bg"
  81.        bg.class="group"
  82.        bg.horiz=1
  83.         bg.0=Button("parent","_Parent")
  84.         bg.1=Button("reload","_Reload")
  85.  
  86.     if NewObj("Application","app")>0 then exit
  87.  
  88.     call Notify("WIN","CLOSEREQUEST",1,"APP","RETURNID","QUIT")
  89.  
  90.     call Notify("dirl","status",0,"lamp","set","color","Error")
  91.     call Notify("dirl","status",1,"lamp","set","color","LoadingData")
  92.     call Notify("dirl","status",2,"lamp","set","color","OK")
  93.     call Notify("dirl","DoubleClick","EveryTime","app","Return","call ChangeDir('D')")
  94.     call Notify("dirl","Active","EveryTime","app","Return","call ChangeActive(h.path)","Path")
  95.  
  96.     call Notify("dir","NewContents","EveryTime","app","Return","call ChangeDir('S')")
  97.     call Notify("ap","NewContents","EveryTime","dirl","set","AcceptPattern","TriggerValue")
  98.     call Notify("rp","NewContents","EveryTime","dirl","set","RejectPattern","TriggerValue")
  99.     call Notify("stype","Active","EveryTime","dirl","set","SortType","TriggerValue")
  100.     call Notify("sdirs","Active","EveryTime","dirl","set","SortDirs","TriggerValue")
  101.     call Notify("ar","Selected","EveryTime","dirl","set","AutoReRead","TriggerValue")
  102.     call Notify("fo","Selected","EveryTime","dirl","set","FilesOnly","TriggerValue")
  103.     call Notify("do","Selected","EveryTime","dirl","set","DrawersOnly","TriggerValue")
  104.     call Notify("ri","Selected","EveryTime","dirl","set","RejectIcons","TriggerValue")
  105.  
  106.     call Notify("parent","Pressed",1,"app","Return","call ChangeDir('P')")
  107.     call Notify("reload","pressed",0,"dirl","ReRead")
  108.  
  109.     call Notify("Dirl","Status","EveryTime","App","Return","call MakeTitle(h.status)","TriggerAttr")
  110.  
  111.     call set("win","open",1)
  112.  
  113.     return
  114. /***********************************************************************/
  115. HandleApp: procedure expose global.
  116.  
  117.     ctrl_c=2**12
  118.     do forever
  119.         call NewHandle("app","h",ctrl_c)
  120.         if and(h.signals,ctrl_c)>0 then exit
  121.         select
  122.             when h.event="QUIT" then exit
  123.             otherwise interpret h.event
  124.         end
  125.     end
  126.     /* never reached */
  127. /***********************************************************************/
  128. ChangeDir: procedure
  129. parse arg where
  130.     select
  131.         when where="D" then do
  132.             call DoMethod("dirl","GetEntry","Active","a")
  133.             if a.entrytype>0 then do
  134.                 call pragma("D",a.name)
  135.                 call set("dirl","Directory",pragma("D"))
  136.                 call set("dir","Contents",pragma("D"))
  137.             end
  138.         end
  139.         when where="S" then do
  140.             d=xget("dir","Contents")
  141.             parse value(Statef(d)) with t .
  142.             if t=="DIR" then do
  143.                 call pragma("D",d)
  144.                 call set("dirl","Directory",pragma("D"))
  145.             end
  146.             else call set("dirl","Directory","")
  147.         end
  148.         when where="P" then do
  149.             d=pragma("D")
  150.             d=PathPart(d)
  151.             call pragma("D",d)
  152.             call set("dirl","Directory",pragma("D"))
  153.             call set("dir","Contents",pragma("D"))
  154.         end
  155.     end
  156.     return
  157. /***********************************************************************/
  158. MakeTitle: procedure
  159. parse arg status
  160.     select
  161.         when status=0 then t="Invalid dir"
  162.         when status=1 then t="Reading..."
  163.         when status=2 then do
  164.             nb=xget("Dirl","NumBytes")
  165.             nd=xget("Dirl","NumDrawers")
  166.             nf=xget("Dirl","NumFiles")
  167.             t="[Bytes:" nb"] [Drawers:" nd"] [Files:" nf"]"
  168.         end
  169.     end
  170.     call set("info","contents",t)
  171.     return
  172. /**************************************************************************/
  173. ChangeActive: procedure
  174. parse arg p
  175.     call set("ainfo","Contents",p)
  176.     return
  177. /**************************************************************************/
  178. halt:
  179. break_c:
  180.     exit
  181. /**************************************************************************/
  182.